#include <iostream>
#include <QtCore/qobject.h>
#include <kurl.h>
#include <syndication/loader.h>

using namespace std;

class RSSAggregator : public QObject
{
    Q_OBJECT
 
  public:

    RSSAggregator()
    {
        loader = Syndication::Loader::create();
        QObject::connect(
            loader,
            SIGNAL(loadingComplete(Syndication::Loader*, Syndication::FeedPtr, Syndication::ErrorCode)),
            this,
            SLOT(slotLoadingComplete(Syndication::Loader*, Syndication::FeedPtr, Syndication::ErrorCode))
        );
    }

    virtual void load() {
        loader->loadFrom(KUrl("https://code.google.com/feeds/p/fragile-bot/svnchanges/basic"));
    }

  public slots:
    void slotLoadingComplete(Syndication::Loader* loader,
                             Syndication::FeedPtr feed,
                             Syndication::ErrorCode status)
    {
        if (status != Syndication::Success)
            return;

        QString title = feed->title();
        cout << title.toStdString() << endl;
    }

  private:
    Syndication::Loader* loader;
};

int main( int argc, char* argv[] )
{
    RSSAggregator* rss = new RSSAggregator();
    rss->load();
}

#include "rss.moc"
